package jsyf.oa.dao.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.system.Company2bankEntity;
import jsyf.oa.entity.system.CompanyStockEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class Company2bankDao extends BaseDao {

    public Company2bankDao() {
        super.iBaseEntity = new Company2bankEntity();
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, Company2bankEntity.class);
    }

    public List<JSONObject> getBanksByCompanyId(String companyId) {
        StringBuffer sb = new StringBuffer();
        sb.append("SELECT\n" +
                "\tt_sys_company_2_bank.id AS id,\n" +
                "\tt_sys_company_2_bank.COMPANY_ID AS companyId,\n" +
                "\tt_sys_company_2_bank.BANK_NAME AS bankName,\n" +
                "\tt_sys_company_2_bank.BANK_CARD AS bankCard\n" +
                "FROM\n" +
                "\tt_sys_company_2_bank\n" +
                "LEFT JOIN t_sys_company ON t_sys_company.ID = t_sys_company_2_bank.COMPANY_ID\n" +
                "WHERE\n" +
                "\t1 = 1\n" +
                "AND t_sys_company.DEL_FLAG = 0\n" +
                "AND t_sys_company_2_bank.COMPANY_ID = '" + companyId + "'\n" +
                "ORDER BY\n" +
                "\tt_sys_company_2_bank.SORT_NO\n");
        return super.queryForJsonList(sb.toString());
    }

}
